package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	import net.flashpunk.Graphic;	
	import net.flashpunk.graphics.Image;
	import net.flashpunk.Sfx;
	
	/**
	 * ...
	 * @author Edward Russell II
	 */
	public class Bullet extends Entity 
	{
		protected var image:Image;
		protected var sfxShoot:Sfx = new Sfx(GC.SFX_SHOOT);
		
		public function Bullet(_graphic:Class,x:Number=0, y:Number=0,_scale:Number=1) 
		{
			//Setup the properties of the bullet
			image = new Image(_graphic);
			graphic = image;
			layer = -3
			image.scale = _scale;
			setHitbox(8, 5)
			type = "bullet"
			
			//play the sound effect
			sfxShoot.play();
			
			super(x, y);
			
		}
		
		override public function update():void 
		{
			//Advance the bullet to the right
			x += GV.BULLET_SPEED * FP.elapsed;
			
			//If the bullet goes off the screen, remove it
			if (x > FP.camera.x + FP.screen.width) world.remove(this);
			
			//If the bullet hits an enemy, remove it
			if (collide("enemy", x, y)) world.remove(this);
			if (collide("level", x, y)) world.remove(this);
			
			super.update();
		}
	}

}